package com.demo.controller;

import com.demo.entity.Carousel;
import com.demo.entity.Role;
import com.demo.model.JsonMessage;
import com.demo.security.AuthUserDetail;
import com.demo.service.CarouselService;
import com.demo.service.RoleService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;

@Controller
@RequestMapping("/carousel")
public class CarouselController {
    @Autowired
    private CarouselService service;

    @PostMapping("findAllCarousel")
    @ResponseBody
    public JsonMessage findAllCarousel() {
        JsonMessage message = new JsonMessage();
        List<Carousel> list = service.findAllCarousel();
        message.setData(list);
        return message;
    }

    @PostMapping("insertCarousel")
    @ResponseBody
    public JsonMessage insertCarousel(String imgPath) {
        JsonMessage message = new JsonMessage();
        service.insertCarousel(imgPath);
        message.setData("ok");
        return message;
    }

    @PostMapping("deleteCarousel")
    @ResponseBody
    public JsonMessage deleteCarousel(int carouselId) {
        JsonMessage message = new JsonMessage();
        service.deleteCarousel(carouselId);
        message.setData("ok");
        return message;
    }


}
